<?php
require_once('./includes/headers.inc.php');
require_once('./top.php');

$error = FALSE;
$user_id = $_GET['id'];

$user_info = $userMgr->get($user_id, $_SESSION['user']['id']);
if(!$user_info['id']) {
    header('Location: /notfound.php');
    exit();
}
$name = $user_info['name'];

$friends = $userMgr->getFriends($user_id);
$friends_list = array('<ul>');
foreach($friends as $row) {
    $friends_list[] = '<li><a href="/viewuser.php?id=' . $row['id'] . '">' . $row['name'] . '</a>';
}
$friends_list[] = '</ul>';

$replaces = array(
    'friends_list'              => implode("\n", $friends_list),
    //'name'                      => $name,
    'error'                     => $msgMgr->formatMsg($error),
);
$lang = array(
    'header_viewfriends'        => $langMgr->get('header_viewfriends', false, array('name' => $name)),
    'header_findfriends'        => $langMgr->get('header_findfriends'),
    'text_findfriends_intro'    => $langMgr->get('text_findfriends_intro'),
    'btn_search'                => $langMgr->get('btn_search'),
);
$templateMgr->loadContent(basename(__FILE__, '.php'), array_merge($replaces, $lang));
?>
